package com.bj58.groupbuy.action.service.impl;

import java.util.List;

import com.bj58.groupbuy.action.db.CommonDao;
import com.bj58.groupbuy.action.db.DBConfig;
import com.bj58.groupbuy.action.model.UserRole;
import com.bj58.groupbuy.action.service.UserRoleService;

public class UserRoleServiceImpl implements UserRoleService{
	private static CommonDao comDao = new CommonDao();
	@Override
	public List<UserRole> getByRoleid(long roleid) throws Exception {
		String sql = "select * from user_role where roleid='"+roleid+"'";
		List<UserRole> roleList=comDao.getAllColsByVo(sql, UserRole.class, DBConfig.db_68_bi_sys.getIntType());
		if(null != roleList &&  !roleList.isEmpty()){
			return roleList;
		}
		return null;
	}

	@Override
	public List<UserRole> getByUserid(long userid) throws Exception {
		String sql = "select * from user_role where userid='"+userid+"'";
		List<UserRole> roleList=comDao.getAllColsByVo(sql, UserRole.class, DBConfig.db_68_bi_sys.getIntType());
		if(null != roleList &&  !roleList.isEmpty()){
			return roleList;
		}
		return null;
	}

	@Override
	public boolean delByRoleid(long roleid) throws Exception {
		return comDao.deleteData("user_role", " and roleid='"+roleid+"'", DBConfig.db_68_bi_sys.getIntType());
	}

	@Override
	public boolean delByUserid(long userid) throws Exception {
		return comDao.deleteData("user_role", " and userid='"+userid+"'", DBConfig.db_68_bi_sys.getIntType());
	}
	
}
